package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketUser;
import com.cskaoyan.market.db.domain.MarketUserExample;
import com.cskaoyan.market.db.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserServiceImpl
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2024/3/28 9:52
 * @Version V1.0
 **/
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    MarketUserMapper userMapper;

    @Override
    public MarketUser login(String username, String password) {
        MarketUserExample marketUserExample = new MarketUserExample();
        MarketUserExample.Criteria criteria = marketUserExample.createCriteria();
        criteria.andUsernameEqualTo(username).andPasswordEqualTo(password);
        MarketUser user = userMapper.selectOneByExample(marketUserExample);
        return user;
    }

    @Override
    public MarketUser selectByUsername(String username) {
        MarketUserExample marketUserExample = new MarketUserExample();
        MarketUserExample.Criteria criteria = marketUserExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        return userMapper.selectOneByExample(marketUserExample);
    }
}
